class MyArray<E>{
    public Object[] array = new Object[10];


    public void setVal(int pos,E val) {
        array[pos] = val;
    }

    public E getVal(int pos) {
        return (E)array[pos];
    }
}

//sealed修饰Animal 代表当前类是密封类  必须有子类
sealed class Animal permits PetDog2,Dog{

}

non-sealed class PetDog2 extends Animal {

}

//Dog 这个类  没有限制 可以被任何类继承
non-sealed class Dog extends Animal {

}
class PetDog extends Dog {

}

public class Test {

    //var name = "fsadfsa";

    public static void main(String[] args) {
        var name = "zhangsan";
        var age = 10;


    }
    public static void main4(String[] args) {
        String data = "one" ;
        int result = switch (data) {
            case "one" : yield  1;
            case "two": yield 2;
            default : yield -1;
        };
        System.out.println(result) ;
    }

    public static void main3(String[] args) {
        String data = "one" ;
        int result = switch (data) {
            case "one"->1;
            case "two"->2;
            default->-1;
        };
        System.out.println(result);
    }

    public static void main2(String[] args) {
        String data = "one" ;
        int result = 0 ; // 接收数据的返回值
        switch (data) {
            case "one":
                result = 1 ; // 为result重新赋值
                break ;
            case "two":
                result = 2 ; // 为result重新赋值
                break ;
            default:
                result = -1 ; // 为result重新赋值
                break ;
        }
        System.out.println(result) ;
    }



    public static void main1(String[] args) {
        MyArray<Integer> array = new MyArray<>();
        array.setVal(0,10);
        array.setVal(1,20);
        //array.setVal(2,"hello");
        int val = array.getVal(0);
        System.out.println(val);
    }
}
